<?php
include_once(dirname(__FILE__).'/class.phpmailer.php');
        include_once(APPROOT.'/web.config.php');


            $mail = new PHPMailer;

            $mail->IsSMTP();                                      // Set mailer to use SMTP
            $mail->SMTPDebug  = 0;
            $mail->Host = mailHost;  // Specify main and backup server
            $mail->SMTPAuth = true;                               // Enable SMTP authentication
            $mail->Port       = mailPort; 
            $mail->CharSet = "UTF-8"; 
            $mail->Username = mailUsername;                            // SMTP username
            $mail->Password = mailPassword;                           // SMTP password
            $mail->SMTPSecure = 'ssl';                            // Enable encryption, 'ssl' also accepted

            $mail->From = mailFormmail;
            $mail->FromName = mailFormname;
            //$mail->AddCC('935773503@qq.com');
            //$mail->AddAddress('862001316@qq.com', 'yxw_8');  // Add a recipient
            if($address){
                foreach ($address as $key => $value) {
			$mail->AddAddress($value, $value); 
				}
                
            }
            if($ccaddress){
                foreach ($ccaddress as $key => $value) {
			$mail->AddCC($value, $value); 
				}
                
            }
            
            //$mail->AddAddress('ellen@example.com');               // Name is optional
            $mail->AddReplyTo(mailUsername, AddReplyToname);
            //$mail->AddCC('935773503@qq.com');
           /* if($addcc){
                    foreach ($address as $key => $value) {
			$mail->AddCC($value, $value); 
				}
            }  */             
            //$mail->AddBCC('bcc@example.com');          //密送

            $mail->WordWrap = 100;                                 // Set word wrap to 50 characters
            //$mail->AddAttachment('/var/tmp/file.tar.gz');         // Add attachments附件
            //$mail->AddAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name附件
            $mail->IsHTML(true);                                  // Set email format to HTML

            $mail->Subject = $mailsubject;
            $mail->Body    = $body;
            $mail->AltBody = $body;

            if(!$mail->Send()) {
              // echo 'Message could not be sent.';
               return 'Mailer Error: ' . $mail->ErrorInfo;
               
            }
            $mail->clearAddresses();
                return 'SUCCESS';
                
                
                
?>                